package com.sunlands.zlcx.usercenter.vo;

import com.sunlands.zlcx.usercenter.domain.LatestVersionDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * @author anjl
 * @date 1:02 PM 2019/4/15
 * description:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class LatestVersionVO implements Serializable {

    private static final long serialVersionUID = 7874133197780584260L;
    private Long id;

    @ApiModelProperty(position = 10, value = "客户端平台")
    private String app;

    @ApiModelProperty(position = 10, value = "最新版本")
    private String latestVersion;

    @ApiModelProperty(position = 10, value = "最低支持版本")
    private String minSupportVersion;

    @ApiModelProperty(position = 10, value = "下载地址")
    private String url;

    @ApiModelProperty(position = 10, value = "提示文案")
    private String tip;
    @ApiModelProperty(position = 10, value = "是否强制升级")
    private Boolean forceUpdate;
    @ApiModelProperty(position = 10, value = "强制提示文案")
    private String forceTip;


    public static LatestVersionVO from(LatestVersionDO version) {
        return Objects.isNull(version) ? null :
                LatestVersionVO
                        .builder()
                        .id(version.getId())
                        .app(version.getApp())
                        .latestVersion(version.getLatestVersion())
                        .minSupportVersion(version.getMinSupportVersion())
                        .tip(version.getTip())
                        .url(version.getUrl())
                        .forceTip(version.getForceTip())
                        .build();
    }
}
